// 头条视频数据服务
export const mockToutiaoData = {
  // 视频列表数据
  videos: [
    {
      id: 'tt123456789',  // 头条视频ID
      itemId: '7341879523012551449',  // 头条特有的itemId
      title: '头条新闻：每日热点播报',
      cover: 'https://picsum.photos/id/239/640/360',  // 使用直接图片URL
      videoUrl: 'https://aigc-files.bigmodel.cn/api/cogvideo/927c8f92-71ed-11f0-9a73-0e3f78bb420c_2.mp4',  // 使用直接视频URL
      embedUrl: 'https://toutiao.com/embed/video/7341879523012551449',
      author: {
        id: 'toutiao_user123',
        name: '新闻直播间',
        avatar: '/src/assets/images/avatar/7.jpg',
        verified: true,
        followers: '321.5万'
      },
      stats: {
        views: '567.8万',
        likes: '32.4万',
        comments: '6789',
        shares: '4.3万',
        collects: '7.8万'
      },
      tags: ['新闻', '热点', '时事'],
      description: '每日热点新闻播报，让你足不出户了解天下事！#新闻 #热点',
      duration: '2:15',
      publishTime: '2024-03-21 08:00:00',
      status: 'normal'
    },
    {
      id: 'tt987654321',
      itemId: '7341879523012551450',
      title: '健康养生：春季养生小常识',
      cover: 'https://picsum.photos/id/242/640/360',  // 更新为直接图片URL
      videoUrl: 'https://aigc-files.bigmodel.cn/api/cogvideo/927c8f92-71ed-11f0-9a73-0e3f78bb420c_5.mp4',  // 更新为直接视频URL
      embedUrl: 'https://toutiao.com/embed/video/7341879523012551450',
      author: {
        id: 'health_expert',
        name: '健康专家',
        avatar: '/src/assets/images/avatar/8.jpg',
        verified: true,
        followers: '215.7万'
      },
      stats: {
        views: '389.2万',
        likes: '25.3万',
        comments: '4567',
        shares: '3.2万',
        collects: '6.5万'
      },
      tags: ['健康', '养生', '春季'],
      description: '春季养生小常识，教你如何保持身体健康，远离疾病！#健康 #养生',
      duration: '3:50',
      publishTime: '2024-03-20 15:20:00',
      status: 'normal'
    }
  ],

  // 获取视频列表
  getVideoList() {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          list: this.videos,
          total: this.videos.length
        })
      }, 300)
    })
  },

  // 获取视频详情
  getVideoDetail(id) {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        const video = this.videos.find((v) => v.id === id)
        if (video) {
          resolve(video)
        } else {
          reject(new Error('视频不存在'))
        }
      }, 200)
    })
  },

  // 获取视频统计数据
  getVideoStats(id) {
    return new Promise((resolve) => {
      setTimeout(() => {
        const video = this.videos.find((v) => v.id === id)
        if (video) {
          // 模拟实时数据变化
          const randomIncrease = (num) => {
            const base = parseInt(num.replace(/[^\d]/g, ''))
            return base + Math.floor(Math.random() * 100)
          }

          resolve({
            ...video.stats,
            views: randomIncrease(video.stats.views),
            likes: randomIncrease(video.stats.likes),
            comments: randomIncrease(video.stats.comments)
          })
        } else {
          resolve({})
        }
      }, 200)
    })
  },

  // 获取视频播放URL
  getVideoUrl(video) {
    return video.embedUrl || video.videoUrl
  }
}